Worksheet 7, Math 151

Antiderivatives, The Fundamental Theorem and Differential Equations

Introduction

Goals: Learn how to find antiderivatives (integrals) using Mathematica, how to solve differential equations and how to understand the fundamental theorem from a Mathematica perspective.

Examples

Antiderivatives

Mathematica is pretty good at finding antiderivatives.

Integrate[x^3,x]

We can verify the correctness of an antiderivative by taking its derivative (remember that % refers to the most recent Mathematica output, i.e., here this is the result of the Integrate[] command).

Integrate[x^3,x]
D[%,x]

Mathematica says that (1/4)(x^4) is an antiderivative of (x^3). The derivative of (1/4)(x^4) is (x^3). So this is correct.
The same thing, but in one step:

D[Integrate[x^3,x],x]

The Fundamental Theorem of Calculus

The first part of the Fundamental Theorem states that for any continuous function f on [a,b], the function F(x)=(∫_a^x)f(t)dt is differentiable on [a,b] and F'(x)=(d/dx)(∫_a^x)f(t)dt=f(x).
In other words, if we have a definite integral with variable upper limit, then the rate of change with respect to the upper limit is precisely the value of the integrand evaluated at the upper limit.

The second part of the Fundamental Theorem states that for every continuous function f on [a,b]
(∫_a^b)f(t)dt=F(b)-F(a),
where F is some antiderivative of f.
Thus, this gives a way to evaluate definite integrals.
Note that we are using "=" to define our function instead of ":=". This speeds up the performance of the animation below quite significantly.

We define an interval [a,b], and a function f with which we want to illustrate the Fundamental Theorem.
Moreover, for the animations below we also find the maximum and minimum values for f on [a,b].

a=-1;
b=3;
f[x_]=(Sqrt[Abs[x]])-(3/2)x+1
max=MaxValue[{f[x],a≤x≤b},x];
min=MinValue[{f[x],a≤x≤b},x];

First we use Mathematica to directly compute the integral
(∫_a^b)f(x)dx, the left-hand side of the Fundamental Theorem.

lhs=Integrate[f[x],{x,a,b}]

Next we compute the function F(x)=(∫_a^x)f(t)dt. We add the assumption x ≥ a  to prevent Mathematica from going off and doing too general calculations with complex functions.

intf[x_]=Integrate[f[t],{t,a,x},Assumptions->x≥a];

And now we check if
(∫_a^b)f(t)dt=F(b)-F(a).

lhs==intf[b]-intf[a]

The following procedure produces an animation which illustrates the Fundamental Theorem.
We will use the derivative F' of the function F(x)=(∫_a^x)f(t)dt which we called inft above.
By moving the slider you change the value of x.
The information displayed during the animation is 
the increment Δx we use when going from one frame to the next,
the current area under the graph, i.e., F(x)=(∫_a^x)f(t)dt,
the previous area, i.e., for x-Δ x,
the approximate rate of change of the area, i.e.,  ((F(x)-F(x-Δ x))/(Δ x)),
the exact rate of change given by F'(x),
and also as guaranteed by the Fundamental Theorem, i.e., f(x).

dx=0.1;
Manipulate[Column[{
Row[{"increment=",dx}],Row[{"previous area=",N[intf[x-dx]]}],Row[{"current area=",N[intf[x]]}],Row[{"approx. rate of change=",(1/dx)*(N[intf[x]]-N[intf[x-dx]])}],
Row[{"F'(x)=",N[intf'[x]]}],Row[{"f(x)=",N[f[x]]}],Plot[f[t],{t,a,x},Filling->Axis,PlotRange->{{a,b},{min,max}}]}],{x,a+dx,b,dx}]

Here's another animation tat is a little fancier. It also allows you to change the increment Δx with a slider.
Note that the animation runs into problems (i.e., produces out of range results) when x-Δ x becomes too small. To prevent it from crashing we've added the If[] statement at the beginning of the code.
Observe how the different rate of change values become closer as Δ x is chosen smaller.
You could make the same observation with the previous Manipulate[] if you manually change the value of the variable dx outside Manipulate[].

Manipulate[If[x<a+dx,x=a+1.001dx];Column[{
Row[{"previous area=",N[intf[x-dx]]}],Row[{"current area=",N[intf[x]]}],Row[{"approx. rate of change=",(1./dx)*(N[intf[x]]-N[intf[x-dx]])}],
Row[{"F'(x)=",N[intf'[x]]}],Row[{"f(x)=",N[f[x]]}],Show[Plot[f[t],{t,a,x-dx},Filling->Axis,PlotRange->{{a,b},{min,max}}],Plot[f[t],{t,x-dx,x},Filling->Axis,FillingStyle-> Directive[Opacity[0.5],Red],PlotRange->{{a,b},{min,max}}, PlotStyle-> Red]]}],{{x,1},a,b,dx},{{dx,0.1},(b-a)*10^(-5),(b-a)/2}]

Differential Equations

A differential equation is an equation which involves an unknown function along with some of its derivatives.
The solution of a differential equation is a function.

A Simple Model for Free Fall

Newton's second law states that force is equal to mass times acceleration, where acceleration is the change in velocity, i.e.,
F=m (dv/dt).
Near the earth's surface, the force due to gravity is the weight of an object, i.e.,
F=mg.
If we assume we are in a vacuum and no other forces are acting, then balancing these two forces leads to the simple differential equation for the free fall velocity of a body:
m(dv/dt)=m g or (dv/dt)=g.
The solution (found by straightforward integration) of this model is
v(t)=∫(dv/dt)dt=∫g dt=g t+C.
And if the velocity at t=1 is equal to g, i.e., v(1)=g, then C=0 and v(t)=g t.
In addition to using integration, we can solve (also much more complicated) differential equations in Mathematica using the built-in DSolve command.

soln=DSolve[{v'[t]==g,v[1]==g},v[t],t]

We can also assign the value of g into the solution:

soln/.{g->9.81}

Without using DSolve we could integrate the equation ∫(dv/dt)dt=∫g dt from above "by hand", i.e.,

soln=Solve[Integrate[v'[t],t]==Integrate[g,t],v[t]]
soln/.{g->9.81}

Exercises

Exercise 1

((x^4)/4) is an antiderivative of (x^3). Of course, you know that there are other antiderivatives of (x^3).
(a) Name one other antiderivative of (x^3).

(b) Find an antiderivative of (1/(4+(x^2))).

(c) Find an antiderivative of (1/(2+(x^4))).

(d) Find an antiderivative of (2^(((x^2)))).

Exercise 2

(a) Have Mathematica find the antiderivative of ((tan(x))^3), and have Mathematica check that its derivative is what it should be.

(b) Have Mathematica find the antiderivative of (1/(1+(x^4))), and have Mathematica compute its derivative.  (Do not simplify.)

Exercise 3

Let f(x)=(x^3)-4(x^2)+3x, and [a,b]=[0,4]. Also let F(x)=(∫_a^x)f(t)dt.

Create an animation similar to the one above in the example for the Fundamental Theorem and discuss what is happening.

Solve F'(x)=0 by hand and then with Mathematica and compare the results. What can you observe about the graphs of f and F' at points where F'(x)=0?

On what intervals is the function F' increasing or decreasing? What can you say about f on those intervals?

Exercise 4

The law of mass action states that the rate of a chemical reaction is proportional to the product of the concentrations of A and B, i.e.,
((d[C])/(d t))=k[A][B],
where [A], [B], and [C] are all functions, and k is a constant.
Let's assume the initial concentrations of A and B are equal, and write [A](0)=[B](0)=a. If we write c(t)=[C](t) for the concentration of C at time t, then the concentration of A (as well as that of B) at time t is [A](t)=a-[C](t).
Therefore, in our case, the law of mass action can be stated as
((d c)/(d t))=((k(a-c))^2).

Use Mathematica's DSolve command to find c, the concentration of C, as a function of t.
Hint: the reaction begins with an initial concentration [C](0)=0.